package org.elfen.common.entity;

import org.elfen.common.base.BaseEntity;
import org.elfen.common.util.DataUtil;

import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;

/**
 * 系统日志实体
 * 
 * 
DROP TABLE IF EXISTS `sys_log`;
CREATE TABLE `sys_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `createTime` datetime DEFAULT NULL COMMENT '创建时间',
  `createBy` varchar(100) DEFAULT '' COMMENT '创建人',
   isDelete  int(2) DEFAULT '0' COMMENT '是否已删除：0-未删除，1-删除',
  
  `title` varchar(256) DEFAULT ''  COMMENT '主题',
  `requestUri` varchar(1024) DEFAULT ''  COMMENT '请求地址',
  `parameters` varchar(1024) DEFAULT ''  COMMENT '请求参数',
  `methodName` varchar(1024) DEFAULT ''  COMMENT 'controller的方法',
  `clientHost` varchar(1024) DEFAULT '' COMMENT '客户端主机',
  `userAgent` varchar(1024) DEFAULT ''  COMMENT '客户端信息',
  `method` varchar(1024) DEFAULT ''  COMMENT '请求方式：post、get等',
  requestTime int(20) comment '执行耗时，单位毫秒',
  `remark` text  COMMENT '响应信息',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='操作日志表';


 */
@TableName("sys_log")
@SuppressWarnings("serial")
public class SysLog extends BaseEntity {
	
	private String title;
	private String requestUri;
	private String parameters;
	private String methodName;
	private String clientHost;
	private String userAgent;
	private String method;
	private Long requestTime;
	private String remark;
	
	@Override
	public Wrapper<SysLog> bindingQueryWrapper() {
		Wrapper<SysLog> wr = new EntityWrapper<SysLog>();
		if(DataUtil.isNotEmpty(title)){
			wr.like("title", title);
		}
		if(DataUtil.isNotEmpty(clientHost)){
			wr.eq("clientHost", clientHost);
		}
		return wr;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getRequestUri() {
		return requestUri;
	}

	public void setRequestUri(String requestUri) {
		this.requestUri = requestUri;
	}

	public String getParameters() {
		return parameters;
	}

	public void setParameters(String parameters) {
		this.parameters = parameters;
	}

	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	public String getClientHost() {
		return clientHost;
	}

	public void setClientHost(String clientHost) {
		this.clientHost = clientHost;
	}

	public String getUserAgent() {
		return userAgent;
	}

	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public Long getRequestTime() {
		return requestTime;
	}

	public void setRequestTime(Long requestTime) {
		this.requestTime = requestTime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((clientHost == null) ? 0 : clientHost.hashCode());
		result = prime * result + ((method == null) ? 0 : method.hashCode());
		result = prime * result
				+ ((methodName == null) ? 0 : methodName.hashCode());
		result = prime * result
				+ ((parameters == null) ? 0 : parameters.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result
				+ ((requestTime == null) ? 0 : requestTime.hashCode());
		result = prime * result
				+ ((requestUri == null) ? 0 : requestUri.hashCode());
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		result = prime * result
				+ ((userAgent == null) ? 0 : userAgent.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		SysLog other = (SysLog) obj;
		if (clientHost == null) {
			if (other.clientHost != null)
				return false;
		} else if (!clientHost.equals(other.clientHost))
			return false;
		if (method == null) {
			if (other.method != null)
				return false;
		} else if (!method.equals(other.method))
			return false;
		if (methodName == null) {
			if (other.methodName != null)
				return false;
		} else if (!methodName.equals(other.methodName))
			return false;
		if (parameters == null) {
			if (other.parameters != null)
				return false;
		} else if (!parameters.equals(other.parameters))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (requestTime == null) {
			if (other.requestTime != null)
				return false;
		} else if (!requestTime.equals(other.requestTime))
			return false;
		if (requestUri == null) {
			if (other.requestUri != null)
				return false;
		} else if (!requestUri.equals(other.requestUri))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		if (userAgent == null) {
			if (other.userAgent != null)
				return false;
		} else if (!userAgent.equals(other.userAgent))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "SysLog [title=" + title + ", requestUri=" + requestUri
				+ ", parameters=" + parameters + ", methodName=" + methodName
				+ ", clientHost=" + clientHost + ", userAgent=" + userAgent
				+ ", method=" + method + ", requestTime=" + requestTime
				+ ", remark=" + remark + "]";
	}

	
}
